<template>
  <div class="pie-echart">
    <echart :option="option"></echart>
  </div>
</template>

<script setup lang="ts">
import { computed, defineProps, withDefaults } from "vue";
import Echart from "../index";
import { IPieEChartDataType } from "../type/type";
interface Props {
  pieData: IPieEChartDataType[];
  seriesName?: string;
}
const props = withDefaults(defineProps<Props>(), { seriesName: "分类数量" });
const option = computed(() => {
  return {
    tooltip: {
      trigger: "item"
    },
    legend: {
      orient: "horizontal"
    },
    series: [
      {
        name: props.seriesName,
        type: "pie",
        radius: "50%",
        data: props.pieData,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)"
          }
        }
      }
    ]
  };
});
</script>

<style scoped></style>
